# 大类：经营状况
# 小类：税务评级

import json
import time


# 19-税务评级数据-2018-12-12
def get_swlevel(mongo_instance, soup, cid, company):
    print('start 税务评级数据*******')

    if soup.find('div', id='_container_taxcredit'):
        for tr in soup.find('div', id='_container_taxcredit').find('tbody').find_all('tr'):
            item = {}
            tds = tr.find_all('td')
            item['date'] = tds[1].text  # 年份
            item['level'] = tds[2].text  # 纳税评级
            item['type'] = tds[3].text  # 类型
            item['code'] = tds[4].text  # 纳税人识别号
            item['org'] = tds[5].text  # 评价单位
            item['create_at'] = int(time.time())
            item['update_at'] = item['create_at']
            item['company'] = company
            item['company_id'] = cid
            print(item)
            mongo_instance.swlevel.update({'company_id': cid}, item, True)

    print('success 税务评级数据*******')
